// 160.相交链表
package LeetcodeHot100;

public class Solution160 {
    public ListNode getIntersectionNode(ListNode headA, ListNode headB) {
        ListNode curA = headA;
        ListNode curB = headB;
        while (curA != curB) {
            if (curA == null)
                curA = headB;
            if (curB == null)
                curB = headA;
            if (curA == curB)
                return curA;
            curA = curA.next;
            curB = curB.next;
        }
        return curA;
    }
}
